<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //原型链继承 实现：复制原型对象 子类自身原型被覆盖
        // 缺点 多个实例引用会被篡改 
        function SuperType() {
            this.colors = ['red', 'blue', 'green']
        }
        SuperType.prototype.getColors = function () {
            return this.colors
        }
        function SubType() {
            this.demo = 11111
        }
        SubType.prototype.fuck = function () {
            return this.demo
        }
        SubType.prototype = new SuperType()

        var instance1 = new SubType()
        instance1.colors.push('black')
        console.log(instance1.colors) //"red,blue,green,black"
        var instance2 = new SubType();
        console.log(instance2.colors); //"red,blue,green,black"
        console.log(instance2.getColors()); //"red,blue,green,black"
    </script>
</body>

</html>